<?php

class SettingsForm extends CFormModel
{
	private $map = array(
		'settings' => array(
			'general' => array(
				'siteName', 'systemEmail', 'theme'
			),
			'seo' => array(
				'description', 'keywords'
			),
			'localization' => array(
				'defaultLang', 'adminDefaultLang',
			),
		),
		'configuration' => array(
		)
	);
	
	public $description;
	public $keywords;
	
	public $siteName;
	public $systemEmail;
	public $theme;
	
	public $defaultLang;
	public $adminDefaultLang;
//	public $dateFormat;
//	public $adminPaginationPageSize;
//	/*email settings*/
//	
//	public $maintenance;
//	public $useSeoUrl;
//	public $GACode;
	
	public function getMap()
	{
		return $this->map;
	}
	
	public function getCategories()
	{
		return array_keys($this->map['settings']);
	}
	
	public function getConfigurationKeys()
	{
		return array_values($this->map['configuration']);
	}
	
	public function mapCategory($key)
	{
		foreach ($this->map['settings'] as $cat=>$keys)
		{
			if (in_array($key, $keys))
			{
				return $cat;
			}
		}
		return 'system';
	}
	

	public function rules()
	{
		return array(
			array('siteName, systemEmail', 'required'),
			array('description, keywords', 'length', 'max'=>255),
			
			array('description, keywords, defaultLang, adminDefaultLang, siteName, systemEmail, theme', 'safe'),
		);
	}

	public function attributeLabels()
	{
		return array(
			'siteName'=>tt('Site Name'),
			'systemEmail'=>tt('System Email'),
			
			'description'=>tt('Description'),
			'keywords'=>tt('Keywords'),
			
			'defaultLang'=>tt('Default language'),
			'adminDefaultLang'=>tt('Admin default language'),
		);
	}
}